const fs = require('fs');
const path = require('path');

fs.readFile('data.txt', (err, data) => {
    if (err) {
        console.error(err);
        return;
    }

    console.log(data);
    console.log(data.toString());
})

console.log('__dirname + data.txt:', path.resolve(__dirname, 'data.txt'));
console.log('__dirname + /data.txt:', path.resolve(__dirname, '/data.txt'));
console.log('data.txt:', path.resolve('data.txt'));
